package com.robot.mq.listener;

import com.robot.mq.service.MailService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author lin
 */
@Component
@RabbitListener(queues = "email")
public class EmailListener {

    @Autowired
    private MailService mailService;

    @RabbitHandler
    public void executeSms(Map<String, String> map) {
        String to = map.get("to");
        String subject = map.get("subject");
        String text = map.get("text");
        String files=map.get("files");
        mailService.send(to, subject, text,null);
    }
}

